/*
 * BitReader.h
 *
 *  Created on: 22/10/2011
 *      Author: agustin
 */

#ifndef BITREADER_H_
#define BITREADER_H_

#include <stdio.h>
#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>

using namespace std;

class BitReader {
public:
	BitReader(const char* source);
	virtual ~BitReader();

	unsigned char leerBit();
	void posicionar(size_t pos);
	void cerrar();
	void abrir(char* dest);

private:
	unsigned char* buffer;
	struct stat stats;
	size_t bytes_read;
	__blksize_t buff_bit;
	int fd;

	bool bufferLeido();
};

#endif /* BITREADER_H_ */
